<template>
    <div>
        <el-button type="primary" @click="handlerLogin">登录</el-button>
        <el-button type="success" @click="handlerList">获取列表</el-button>
    </div>
</template>

<script setup>
import requestUtil from '@/util/request';
import store from "@/store";
import {useRoute, useRouter} from 'vue-router';
import { ref, reactive } from 'vue';

const router = useRouter();

const handlerLogin = async () => {
    let request = await requestUtil.post('/test/login');
    let data = request.data;
    console.log(data);
    if (data.code == 2000) {
        alert('登录成功！')
        let token = data.result.token;
        console.log("登录成功：token=" + token);
        store.commit('SET_TOKEN', token);
    }else{
        alert('登录出错！')
    }
}

const handlerList = async () => {
    let request = await requestUtil.get('/test/getList');
    let data = request.data;
    console.log('数据：',data);
}

</script>

<style lang="scss" scoped>

</style>